package net.zubara.esni.core;

import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;

/**
 * The activator class controls the plug-in life cycle
 */
public class CorePlugin extends Plugin {

	Log log = LogFactory.getLog(CorePlugin.class);

	// The plug-in ID
	public static final String PLUGIN_ID = "net.zubara.esni.core";

	// The shared instance
	private static CorePlugin plugin;

	private Properties configProperties;

	/**
	 * The constructor
	 */
	public CorePlugin() {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;
		configProperties = new Properties();
		try {
			configProperties.load(this.getClass().getClassLoader().getResourceAsStream("net/zubara/esni/core/config.properties"));
		} catch (Exception e) {
			log.error(e);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
	}

	/**
	 * Returns the shared instance
	 * 
	 * @return the shared instance
	 */
	public static CorePlugin getDefault() {
		return plugin;
	}

	public Properties getConfigProperties() {
		return configProperties;
	}

}
